<template>
  <el-container class="container">
    <el-header class="header">
      <el-row>
        <el-col :span="8">
          <img src="../../assets/images/logo.png" alt>
        </el-col>
        <el-col :span="8">
          <h1>电商后台管理系统</h1>
        </el-col>
        <el-col :span="8" class="out">
          欢迎前端33期会员
          <a href="#" @click.prevent="logout">退出</a>
        </el-col>
      </el-row>
    </el-header>
    <el-container>
      <el-aside class="aside" width="200px">
        <el-menu
          :router="true"
          default-active="1-1"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item index="/users">用户列表</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>权限管理</span>
            </template>
            <el-menu-item index="/roles">角色列表</el-menu-item>
            <el-menu-item index="/rights">权限列表</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main class="main">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  methods: {
    logout() {
      this.$confirm("此操作将退出账户, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          localStorage.removeItem("token");
          this.$router.push("/login");
          this.$message({
            type: "success",
            message: "删除成功!",
            duration: 800
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    handleOpen(key, keyPath) {
      console.log("open");
    },
    handleClose(key, keyPath) {
      console.log("close");
    }
  }
};
</script>

<style lang='less'>
* {
  margin: 0;
  padding: 0;
}
html,
body,
#app {
  height: 100%;
}
.container {
  height: 100%;
  min-width: 870px;
}
.header {
  height: 60px;
  background: #b3c1cd;
  padding: 0;
  h1 {
    color: #fff;
    font-size: 28px;
    text-align: center;
    line-height: 60px;
  }
  .out {
    text-align: right;
    line-height: 60px;
    padding-right: 40px;
    a {
      color: #daa521;
    }
  }
}
.aside {
  background: #545c64;
}
.main {
  background: #eaeef1;
  padding: 0;
}
</style>
